package exercise2;

import javax.swing.JOptionPane;;

public class NumberPlus {
	public static void printNumberPlus() {
		String number = JOptionPane.showInputDialog("请输入三位数的整数(0-999)");
		int x = Integer.parseInt(number);
		if (x < 100 || x > 999) {
			JOptionPane.showMessageDialog(null, "您输入的数不在范围内", "友情提示！", JOptionPane.ERROR_MESSAGE);
		} else {
			int sum = 0;
			int a = x / 100;
			int b = (x / 10) % 10;
			int c = x % 10;
			sum = a + b + c;
			JOptionPane.showMessageDialog(null, "这个数的各个部分之和为：" + sum);
		}
	}
}
